package com.example.math.calculator;

import ktjy.Calculator;

import java.util.Scanner;

public class CalculatorFactory {
    public static Calculator getCalculator() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入操作符（+、-、*、/、%）：");
        String operator = scanner.next();

        switch (operator) {
            case "+":
                return new AddCalculatorFactory().createCalculator();
            case "-":
                return new SubtractCalculatorFactory().createCalculator();
            case "*":
                return new MultiplyCalculatorFactory().createCalculator();
            case "/":
                return new DivideCalculatorFactory().createCalculator();
            case "%":
                return new ModCalculatorFactory().createCalculator();
            default:
                throw new IllegalArgumentException("不支持的操作符");
        }
    }
}
